home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / intpcl.pas < prev    next >
Pascal/Delphi Source File  |  1986-04-05  |  1KB  |  47 lines

  1. {* WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  2.     In order to use the Intr procedure in Turbo Pascal you
  3.     must be familiar with interrupts and have access to a
  4.     technical reference manual.
  5.  
  6.     The following program uses the Intr function in Turbo to
  7.     get the time.  Registers have to be set correctly according
  8.     to the DOS technical reference manual before the function
  9.     is called.
  10.  
  11.     The program simply returns the time in a string at the top
  12.     of the screen.*}
  13.  
  14. program TimeInterrupt;
  15. type
  16.   TimeString = string[8];
  17.  
  18. function time: TimeString;
  19. type
  20.   regpack = record
  21.               ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
  22.             end;
  23.  
  24. var
  25.   recpack:          regpack;             {assign record}
  26.   ah,al,ch,cl,dh:   byte;
  27.   hour,min,sec:     string[2];
  28.  
  29. begin
  30.   ah := $2c;                             {initialize correct registers}
  31.   with recpack do
  32.   begin
  33.     ax := ah shl 8 + al;
  34.   end;
  35.   intr($21,recpack);                     {call interrupt}
  36.   with recpack do
  37.   begin
  38.     str(cx shr 8,hour);                  {convert to string}
  39.     str(cx mod 256,min);                       { " }
  40.     str(dx shr 8,sec);                         { " }
  41.   end;
  42.   time := hour+':'+min+':'+sec;
  43. end;
  44.  
  45. begin
  46.   writeln(time);
  47. end.